package jtmcraft.game.units;

import java.awt.Color;
import jtmcraft.game.Controller;
import jtmcraft.game.units.states.GatherState;
import jtmcraft.game.units.states.MoveState;
import jtmcraft.graphics.Sprite;

/**
 *
 * @author milosz
 */
public class WorkerUnit extends GameUnit {

    public static final int DURABILITY = 20;
    GameUnit home;

    boolean haveGold = false;
    Sprite carrierGoldSprite;

    public WorkerUnit( GameUnit home, Controller actionHandler, Color playerColor ) {
        super( actionHandler );
        this.setDurability( DURABILITY );
        this.setMaxDurability(DURABILITY);
        this.home = home;
        this.setPlayerColor(playerColor);
    }

    @Override
    public void pointEnemy(GameUnit gameUnit) {

    }

    @Override
    public void point(int x, int y) {
        this.getSprite().setMove(true);
        this.setState( new MoveState( x, y ) );
    }

    @Override
    public void pointNeutral(GameUnit gameUnit) {
        this.getSprite().setMove(true);
        if( gameUnit.getClass() == MineUnit.class )
        {
            setState( new GatherState(gameUnit, home));
        }
    }

    public Sprite getCarrierGoldSprite() {
        return carrierGoldSprite;
    }

    public void setCarrierGoldSprite(Sprite carrierGoldSprite) {
        this.carrierGoldSprite = carrierGoldSprite;
    }

    @Override
    public Sprite getSprite() {
        if (haveGold) {
            return carrierGoldSprite;
        } else {
            return sprite;
        }
    }

    public boolean isHaveGold() {
        return haveGold;
    }

    public void setHaveGold(boolean haveGold) {
        this.haveGold = haveGold;
    }

    

}